package com.lej.push.init

import android.app.Application
import android.util.Log
import com.igexin.sdk.PushManager
import com.lej.core.base.BaseInitializer
import com.lej.core.provider.loginStatusChange
import com.lej.core.provider.pushProvider
import com.lej.core.utils.isMainProcess
import com.lej.push.PushUtils
import com.lej.push.provider.PushProviderImpl

class LibPushInitializer : BaseInitializer() {
    override fun onInit(application: Application) = true

    override fun privacyInit(application: Application, isHave: Boolean) {
        if (isHave) {
            pushProvider = PushProviderImpl
            loginStatusChange.add {
                if (it) PushUtils.bindCid() else PushUtils.unBindCid()
            }
            PushManager.getInstance().setDebugLogger(application) { Log.d("PUSH_LOG", it) }
            if (application.isMainProcess()) {
                PushUtils.init(application, true)
            }
        }
    }
}